﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Data.OleDb;

public partial class _Default : System.Web.UI.Page 
{
     public List<Fabrika> rez;
     protected void Page_Load(object sender, EventArgs e)
     {
         ListItem it1 = new ListItem("");
         ListBox1.Items.Add(it1);
         rez = new List<Fabrika>();
     }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Proekt p = new Proekt();
        rez = p.vratiFabriki(Int32.Parse(DD1.SelectedValue.ToString()));
        int i = 0;
        ListBox1.Items.Clear();
        ListItem it1 = new ListItem("");
        ListBox1.Items.Add(it1);
        while (i < rez.Count)
        {
            Fabrika f = rez.ElementAt<Fabrika>(i);
            int r =Int32.Parse(f.ID);
            ListItem it = new ListItem(f.imeFabrika,i.ToString());
            ListBox1.Items.Add(it);
           // ListBox1.Items.Add(f.imeFabrika);
            i++;
        }
     
    }
    protected void DD1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Label2.Text = "ima "+DD1.SelectedValue.ToString();
    }
    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Proekt p = new Proekt();
        rez = p.vratiFabriki(Int32.Parse(DD1.SelectedValue.ToString()));
        String v1 = ListBox1.SelectedValue;
        int v = Int32.Parse(ListBox1.SelectedValue);
        Fabrika f= new Fabrika();
        int dolzina = rez.Count;
        f= rez.ElementAt<Fabrika>(v);
        Label3.Text = "ИМЕ НА ФАБРИКА:  "+f.imeFabrika + " ОПИС: " + f.opis + "  АДРЕСА НА ФАБРИКА: " + f.adresa + " ЦЕНА ЗА ПОСЕТА: " + f.cena;
          }
}
